<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}">
<link href="assets/lib/css/login.css" rel="stylesheet" media="screen">
<link href="assets/lib/css/animate.css" rel="stylesheet" media="screen">
<link href="assets/lib/fonts/font-awesome.min.css" rel="stylesheet">
<script src="assets/lib/js/jquery3.2.js"></script>
<title>用户订单列表</title>
<style type="text/css">
	.yangshi1{
		width:1030px;
		margin:20px 12%;
		float:left;
	}
	.yangshi2{
		margin: 50px 10%;
		float: left;
	}
	td{
		width: 100px;
		align-content: center;
	}
</style>
<script type="text/javascript">
    $(function(){
        $(".pay").click(function(){
            var tr=$(this).parent().parent();
            var td=$(tr).children(":first-child").next();
            var id=$(td).text();
            $.ajax({
                url:"/listServlet/update",
                type:"POST",
                data:{"listid":id,"attitude":"DOING_OUT"},
                dataType:"text",
            }).done(function(txt){
                if(eval(txt)>0){
                   $(tr).children(":nth-child(4)").html("正在配货");
                }
            });
        });
        $(".undo").click(function(){
            var tr=$(this).parent().parent();
            var td=$(tr).children(":first-child").next();
            var id=$(td).text();
            $.ajax({
                url:"/listServlet/update",
                type:"post",
                data:{"listid":id,"attitude":"CANCEL_LIST"},
                dataType:"text",
            }).done(function(txt){
                if(eval(txt)>0){
                    $(tr).children(":nth-child(4)").html("已取消");
                }
            });
        });
    });
</script>
</head>
<body>
	<div class="yangshi1">
		<p style="float: left;">当前用户：${sessionScope.USER.counts }</p>
		<p style="float: right;">上次登录时间：
		    <fmt:formatDate value="${sessionScope.USER.lasttime }" pattern="yyyy-MM-dd HH-mm-ss"/>
		</p>
	</div>
	<div class="yangshi2">
		<table cellpadding="0" cellspacing="0" border="1">
			<thead>
				<tr>
					<th width="100px" align="center">编号</th>
					<th width="100px" align="center">订单编号</th>
					<th width="120px" align="center">订单总金额(元)</th>
					<th width="100px" align="center">订单状态</th>
					<th width="100px" align="center">订单来源</th>
					<th width="200px" align="center">下单时间</th>
					<th width="100px" align="center">收货人姓名</th>
					<th width="100px" align="center">收货人电话</th>
					<th width="200px" align="center">收货人地址</th>
				</tr>
			</thead>
			<tbody>
				<c:if test="${empty sessionScope.LIST }">
					<tr>
						<td colspan="9" align="center">该用户还没有订单</td>
					</tr>
				</c:if>
				<c:if test="${not empty sessionScope.LIST }">
					<c:forEach items="${sessionScope.LIST }" var="lm" varStatus="suoyin">
						<tr>
							<td align="center">${suoyin.index+1}</td>
							<td align="center">${lm.listid}</td>
							<td align="center">
							    <fmt:formatNumber value="${lm.sums}" pattern="0.00"/>
							</td>
							<c:if test="${lm.attutide eq 'NO_PAYMENT'}">
                                <td align="center">
                                    <input class="pay" type="button" value="支付">&nbsp;
                                    <input class="undo" type="button" value="取消">
                                </td>
							</c:if>
							<c:if test="${lm.attutide ne 'NO_PAYMENT'}">
							    <td align="center">${lm.attutide.text}</td>
							</c:if>
							<td align="center">${lm.listfrom.text}</td>
							<td align="center">
							     <fmt:formatDate value="${lm.thistime}" pattern="yyyy-MM-dd HH-mm-ss"/>
							</td>
							<td align="center">${lm.toname}</td>
							<td align="center">${lm.totele}</td>
							<td align="center">${lm.toaddress}</td>
						</tr>
					</c:forEach>
				</c:if>
			</tbody>
		</table>
	</div>
</body>
</html>